package br.com.felix.util.io;

import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.util.List;


/**
 * I don't know how come this does not have a default implementation in the SDK.
 * Implementation of the Transferable interface, to work with the clipboard and JavaFileList.
 * */
public class JavaFileListTransferable implements Transferable, Serializable {

	private static final long serialVersionUID = 7169334250989310707L;
	private List<File> lstFiles;
	
	public JavaFileListTransferable(List<File> lstFiles){
		this.lstFiles = lstFiles;
	}
	
	public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
		if(flavor.equals(DataFlavor.javaFileListFlavor))return lstFiles;
		return null;
	}
	


	public DataFlavor[] getTransferDataFlavors() {
		return new DataFlavor[]{DataFlavor.javaFileListFlavor};
	}
	


	public boolean isDataFlavorSupported(DataFlavor flavor) {
		return flavor.equals(DataFlavor.javaFileListFlavor);
	}
}
